package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pojo.Book;
import service.BookManager;
import service.impl.BookManagerFactory;

/**
 * Servlet implementation class BookStoreServlet
 */
public class BookStoreServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	private BookManager manager;
    
    public BookStoreServlet() {
        super();
       manager= BookManagerFactory.getInstance();
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		List<Book> books = manager.showAllBooks();
		request.setAttribute("books",books);
		
		request.getRequestDispatcher("../bookstore.jsp").forward(request, response);
		
	}

}
